package com.realjinge.message;

import java.util.ArrayList;
import java.util.List;

import com.realjinge.config.WeChatConfig;

/**
 * 消息类
 * 
 * @author realjinge
 * 
 */
public class MessageUtils {

	/**
	 * 初始化图文消息——产品手册
	 * 
	 * @param toUserName
	 * @param fromUserName
	 * @return
	 */
	public static String initProductInfoNews(String toUserName, String fromUserName) {
		List<Item> items = new ArrayList<Item>();
		String title = "【微信公众平台测试账号】";
		String description = "微信公众平台测试账号······\n\n" + "一、测试页面\n" + "二、我要答题\n" + "三、更多~~（real进歌/产品手册/版本信息）";
		String picUrl = "http://www.realjinge.com/zb_users/upload/2017/02/201702271488188287109957.png";
		String url = "http://" + WeChatConfig.DOMAIN_NAME + "/";
		Item item = new Item(title, description, picUrl, url);
		items.add(item);
		String itemStr = "";
		for (int i = 0; i < items.size(); i++) {
			itemStr += MsgXmlResp.buildItem(items.get(i).getTitle(), items.get(i).getDescription(),
					items.get(i).getPicUrl(), items.get(i).getUrl());
		}
		return MsgXmlResp.buildNews(toUserName, fromUserName, Integer.toString(items.size()), itemStr);
	}

}
